home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ada / gnat1792.zip / gnat179b / t-adainc / s-stoele.ads < prev    next >
Text File  |  1994-05-19  |  4KB  |  94 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT COMPILER COMPONENTS                         --
  4. --                                                                          --
  5. --               S Y S T E M . S T O R A G E _ E L E M E N T S              --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.8 $                              --
  10. --                                                                          --
  11. --           Copyright (c) 1992,1993,1994 NYU, All Rights Reserved          --
  12. --                                                                          --
  13. -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  14. -- terms of the  GNU General Public License as published  by the Free Soft- --
  15. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  16. -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  17. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  18. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  19. -- for  more details.  You should have  received  a copy of the GNU General --
  20. -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
  21. -- to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. --
  22. --                                                                          --
  23. ------------------------------------------------------------------------------
  24.  
  25. with Unchecked_Conversion;
  26.  
  27. package System.Storage_Elements is
  28.    --  pragma Pure (System.Storage_Elements);
  29.  
  30.    type Storage_Offset is new Integer;
  31.    subtype Storage_Count is Storage_Offset range 0 .. Storage_Offset'Last;
  32.    subtype Storage_Index is Storage_Offset range 1 .. Storage_Offset'Last;
  33.  
  34.    type Storage_Element is mod 2 ** Storage_Unit;
  35.    for Storage_Element'Size use Storage_Unit;
  36.  
  37.    type Storage_Array is
  38.      array (Storage_Index range <>) of aliased Storage_Element;
  39.    --  for Storage_Array'Component_Size use Storage_Unit;
  40.  
  41.    --  Address arithmetic
  42.  
  43.    function "+" (Left : Address; Right : Storage_Offset) return Address;
  44.    pragma Convention (Intrinsic, "+");
  45.    pragma Inline ("+");
  46.  
  47.    function "+" (Left : Storage_Offset; Right : Address) return Address;
  48.    pragma Convention (Intrinsic, "+");
  49.    pragma Inline ("+");
  50.  
  51.    function "-" (Left : Address; Right : Storage_Offset) return Address;
  52.    pragma Convention (Intrinsic, "-");
  53.    pragma Inline ("-");
  54.  
  55.    function "-" (Left, Right : Address) return Storage_Offset;
  56.    pragma Convention (Intrinsic, "-");
  57.    pragma Inline ("-");
  58.  
  59.    function "mod" (Left : Address; Right : Storage_Offset)
  60.      return Storage_Offset;
  61.    pragma Convention (Intrinsic, "mod");
  62.    pragma Inline ("mod");
  63.  
  64.    --  Conversion to/from integers
  65.  
  66.    type Integer_Address is mod Memory_Size;
  67.  
  68.    function To_Address (Value : Integer_Address) return Address;
  69.    pragma Convention (Intrinsic, To_Address);
  70.    pragma Inline (To_Address);
  71.  
  72.    function To_Integer (Value : Address) return Integer_Address;
  73.    pragma Convention (Intrinsic, To_Integer);
  74.    pragma Inline (To_Integer);
  75.  
  76.    --  Peek/poke functionality
  77.  
  78.    generic
  79.       type Object (<>) is limited private;
  80.  
  81.    package Address_To_Access_Conversions is
  82.       type Object_Pointer is access all Object;
  83.  
  84.       function To_Pointer is new
  85.         Unchecked_Conversion (Address, Object_Pointer);
  86.       pragma Convention (Intrinsic, To_Pointer);
  87.  
  88.       function To_Address is new
  89.         Unchecked_Conversion (Object_Pointer, Address);
  90.       pragma Convention (Intrinsic, To_Address);
  91.    end Address_To_Access_Conversions;
  92.  
  93. end System.Storage_Elements;
  94.